{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1\n",
      "Runoob\n",
      "1    Google\n",
      "2    Runoob\n",
      "3      Wiki\n",
      "dtype: object\n",
      "1    Google\n",
      "C      Wiki\n",
      "Name: RUNOOB-Series-TEST, dtype: object\n"
     ]
    }
   ],
   "source": [
    "# Pandas 数据结构 - Series\n",
    "#\n",
    "'''\n",
    "pandas.Series( data, index, dtype, name, copy)\n",
    "Pandas Series 类似表格中的一个列 (column), 类似于一维数组，可以保存任何数据类型。\n",
    "参数说明：\n",
    "data    - 一组数据(ndarray 类型)。\n",
    "index   - 数据索引标签，如果不指定，默认从 0 开始。\n",
    "dtype   - 数据类型，默认会自己判断。\n",
    "name    - 设置名称。\n",
    "copy    - 拷贝数据，默认为 False。\n",
    "'''\n",
    "import pandas as pd\n",
    "\n",
    "# 如果没有指定索引，索引值就从 0 开始\n",
    "a = [1, 2, 3]\n",
    "myvar = pd.Series(a)\n",
    "print(myvar[0])\n",
    "\n",
    "# 指定索引值\n",
    "a = [\"Google\", \"Runoob\", \"Wiki\"]\n",
    "myvar = pd.Series(a, index=[\"x\", \"y\", \"z\"])\n",
    "print(myvar['y'])\n",
    "\n",
    "# 使用 key/value 对象，类似字典来创建 Series：\n",
    "sites = {1: \"Google\", 2: \"Runoob\", 3: \"Wiki\"}\n",
    "# sites = {'A': \"Google\", 'B': \"Runoob\", 'C': \"Wiki\"}\n",
    "myvar = pd.Series(sites)\n",
    "print(myvar)\n",
    "\n",
    "# 设置 Series 名称参数：\n",
    "sites = {1: \"Google\", 2: \"Runoob\", 'C': \"Wiki\"}\n",
    "myvar = pd.Series(sites, index=[1, 'C'], name='RUNOOB-Series-TEST')\n",
    "print(myvar)\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3.9.9 64-bit",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.9"
  },
  "orig_nbformat": 4,
  "vscode": {
   "interpreter": {
    "hash": "cf18841ace8313d0bc088ca146c17a6c0040e82121d5cb75c0ea07172309253d"
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
